// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   BAG_ADImpl.java

package com.sunwayhorizo.health.hl7.datatypes.common;

import com.sunwayhorizo.health.hl7.common.VersionInfo;
import com.sunwayhorizo.health.hl7.datatypes.AD;
import com.sunwayhorizo.health.hl7.datatypes.ANY;
import com.sunwayhorizo.health.hl7.datatypes.BAG_AD;
import com.sunwayhorizo.health.hl7.datatypes.BL;
import com.sunwayhorizo.health.hl7.datatypes.CS;
import com.sunwayhorizo.health.hl7.datatypes.INT;
import com.sunwayhorizo.health.hl7.datatypes.TYPE;

import java.util.List;


// Referenced classes of package oracle.apps.ctb.hl7.types.common:
//            BAGCommonImpl, ANYImpl, CSImpl, NullFlavorImpl, 
//            TYPEImpl

public class BAG_ADImpl extends BAGCommonImpl
    implements BAG_AD
{

    public static final String RCS_ID = "$Header: BAG_ADImpl.java 115.24 2005/09/16 09:23:59 amchanda noship $";
    public static final boolean RCS_ID_RECORDED = VersionInfo.recordClassVersion("$Header: BAG_ADImpl.java 115.24 2005/09/16 09:23:59 amchanda noship $", "oracle.apps.ctb.hl7.types.common");
    private static final BAG_AD nullNI = new BAG_ADImpl(CSImpl.valueOf("NI"));
    private static final BAG_AD nullOTH = new BAG_ADImpl(CSImpl.valueOf("OTH"));
    private static final BAG_AD nullNINF = new BAG_ADImpl(CSImpl.valueOf("NINF"));
    private static final BAG_AD nullPINF = new BAG_ADImpl(CSImpl.valueOf("PINF"));
    private static final BAG_AD nullUNK = new BAG_ADImpl(CSImpl.valueOf("UNK"));
    private static final BAG_AD nullASKU = new BAG_ADImpl(CSImpl.valueOf("ASKU"));
    private static final BAG_AD nullNAV = new BAG_ADImpl(CSImpl.valueOf("NAV"));
    private static final BAG_AD nullMSK = new BAG_ADImpl(CSImpl.valueOf("MSK"));
    private static final BAG_AD nullNA = new BAG_ADImpl(CSImpl.valueOf("NA"));
    private static final BAG_AD nullNASK = new BAG_ADImpl(CSImpl.valueOf("NASK"));

    public static BAG_AD valueOf(AD aad[])
    {
        return new BAG_ADImpl(aad);
    }

    public static BAG_AD valueOf(AD ad)
    {
        return new BAG_ADImpl(ad);
    }

    public static BAG_AD valueOf(List list)
    {
        if(list == null)
            throw ANYImpl.newNullException("BAG<AD>", "valueOf", "list");
        else
            return new BAG_ADImpl(list);
    }

    protected BAG_ADImpl(AD aad[])
    {
        if(aad == null)
            throw ANYImpl.newNullException("BAG<AD>", "constructor", "elements");
        for(int i = 0; i < aad.length; i++)
            if(aad[i] != null && aad[i].isNull().isFalse())
                mList.add(aad[i]);

    }

    protected BAG_ADImpl(AD ad)
    {
        if(ad == null || ad.isNull().isTrue())
        {
            throw ANYImpl.newNullException("BAG<AD>", "constructor", "element");
        } else
        {
            mList.add(ad);
            return;
        }
    }

    protected BAG_ADImpl(List list)
    {
        super(list);
    }

    protected BAG_ADImpl(CS cs)
    {
        super(cs);
    }

    public INT contains(AD ad)
    {
        return containsANY(ad);
    }

    public BAG_AD plus(BAG_AD bag_ad)
    {
        if(isNull().isTrue())
            return nullBAG_AD(NullFlavorImpl.NI);
        else
            return new BAG_ADImpl(plus(mList, bag_ad.toList()));
    }

    public BAG_AD minus(BAG_AD bag_ad)
    {
        if(isNull().isTrue())
            return nullBAG_AD(NullFlavorImpl.NI);
        else
            return new BAG_ADImpl(minus(mList, bag_ad.toList()));
    }

    public BAG_AD promotion(AD ad)
    {
        return new BAG_ADImpl(promoteItem(ad));
    }

    public TYPE dataType()
    {
        return com.sunwayhorizo.health.hl7.datatypes.common.TYPEImpl.BAG_AD;
    }

    public BL equal(ANY any)
    {
        throw ANYImpl.newUnsupportedException("BAG<AD>", "equal");
    }

    public int hashCode()
    {
        int i = 17;
        if(isNull().isFalse())
            i += mList.hashCode();
        return i;
    }

    protected boolean verifyItem(Object obj)
    {
        return obj instanceof AD;
    }

    public static BAG_AD nullBAG_AD(CS cs)
    {
        String s = null;
        if(cs == null || cs.literal().stringValue() == null || cs.isNull().isTrue())
            s = "NI";
        else
            s = cs.literal().stringValue();
        if(s.equals("NI"))
            return nullNI;
        if(s.equals("OTH"))
            return nullOTH;
        if(s.equals("NINF"))
            return nullNINF;
        if(s.equals("PINF"))
            return nullPINF;
        if(s.equals("UNK"))
            return nullUNK;
        if(s.equals("ASKU"))
            return nullASKU;
        if(s.equals("NAV"))
            return nullNAV;
        if(s.equals("MSK"))
            return nullMSK;
        if(s.equals("NA"))
            return nullNA;
        if(s.equals("NASK"))
            return nullNASK;
        else
            return nullNI;
    }

}
